'''
1.use operation of file and dir
2.count the numbers files of dir
3.func:count_dir(dir_path)
4.dir_path is the path of dir which u want to count
5. does 'count' can define as local variate?????????????if yes, how to do it ?if no, why?
'''
import os

count = 0


def count_dir(dir_path):
    global count
    dir_list = os.listdir(dir_path)
    for f in dir_list:
        file_path = os.path.join(dir_path, f)
        if os.path.isfile(file_path):
            count = count + 1
            print('{}   {}'.format(file_path, count))
        if os.path.isdir(file_path):
            print(count)
            count_dir(file_path)  # recursively call the count function
        print(count)
    # return count


# countDir = count_dir('./')
# print('countDir=', countDir)
count_dir('./')
print('countDir=', count)
